package com.zzxy.spring12.aspect;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

@Component
@Aspect
public class MyAspectJ {
    @Pointcut(value = "execution(* com.zzxy.spring12.service.impl.*.*(..))")
    public void myPoincut(){

    }
    @Before(value = "myPoincut()")
    public void before(JoinPoint joinPoint){
        System.out.println("method name:"+joinPoint.getSignature().getName());
        System.out.println("before..");
    }
    @After(value = "myPoincut()")
    public void after(JoinPoint joinPoint){
        System.out.println("after...");
    }
    public Object myAround(ProceedingJoinPoint pjp) throws Throwable{
        System.out.println("before around...");
        Object obj = pjp.proceed();
        System.out.println("after around...");
        return obj;
    }
    public  void myAfterReturning(JoinPoint joinPoint,Object ret){
        System.out.println("after returning.."+ret);
    }
    public  void myThrowable(JoinPoint joinPoint,Throwable e){
        System.out.println("after returning.."+e);
    }

}
